package com.icode.mvc.util;

import com.icode.mvc.RequestMethod;
import com.icode.mvc.controller.key.Key;
import com.icode.mvc.controller.key.SimpleMethodKey;

import javax.servlet.http.HttpServletRequest;

/**
 * User: Alex Zhong
 * Date: 2016/2/4
 */
public class SimpleMethodKeyGenerator implements KeyGenerator {

    @Override
    public Key generate(HttpServletRequest request) {
        String requestURI = request.getRequestURI();
        String method = request.getMethod().toUpperCase();
        return new SimpleMethodKey(requestURI, RequestMethod.valueOf(method));
    }
}
